package com.chenwc.enums;

/**
 * TLS/SSL 协议枚举
 * @author chenwc
 */
public enum HttpsAlgorithmEnum {
    SSL("SSL"),
    TLS("TLS"),
    TLSV_1_1("TLSv1.1"),
    TLSV_1_2("TLSv1.2");
    //JDK8不支持TLSv1.3
    //TLSV_1_3("TLSv1.3");

    private String algorithm;

    HttpsAlgorithmEnum(String algorithm) {
        this.algorithm = algorithm;
    }

    public String getAlgorithm() {
        return algorithm;
    }

    public void setAlgorithm(String algorithm) {
        this.algorithm = algorithm;
    }

    /**
     * 根据算法名称获取 HttpsAlgorithmEnum
     * @param algo 算法名称
     * @return HttpsAlgorithmEnum
     */
    public HttpsAlgorithmEnum getAlgorithmEnum(String algo) {
        for (HttpsAlgorithmEnum algorithmEnum : HttpsAlgorithmEnum.values()) {
            if (algo.equals(algorithmEnum.getAlgorithm())) {
                return algorithmEnum;
            }
        }
        return null;
    }
}
